﻿namespace EasyCMS.Common.Querys
{
    using System;
    using Pismire.Querys;
    using Pismire;

    [System.Runtime.Serialization.DataContractAttribute(Name = "Member", Namespace = "http://schemas.datacontract.org/2004/07/EasyCMS.Common.Querys")]
    public class Member : Pismire.Querys.QueryBase
    {
        #region key
        /// <summary>
        /// 缓存键
        /// </summary>
        public override string Key
        {
            get { return string.Format(KeyFormat, NickName, RealName, Sex, Wedlock, Exp, Score, Work, Phone, Mobile, IM01, IM02, IM03, IM04, IM05, Address, Signature, Intro, Birthday); }
        }
        private const string KeyFormat = "Member_NickName{0}RealName{1}Sex{2}Wedlock{3}Exp{4}Score{5}Work{6}Phone{7}Mobile{8}IM01{9}IM02{10}IM03{11}IM04{12}IM05{13}Address{14}Signature{15}Intro{16}Birthday{17}";
        #endregion

        #region NickName
        /// <summary>
        /// NickName
        /// </summary>
        public string NickName
        {
            get { return m_NickName; }
            set
            {
                m_NickName = value;
                this.HasNickName = (!String.IsNullOrEmpty(value)) ? true : false;
            }
        }
        private string m_NickName;
        public bool HasNickName { get; private set; }
        public bool NickNameIsLike { get; set; }
        public static ExcuteState NickName_Validate(ref string nickName)
        {
            return nickName.Validation("NickName").LengthBetween(0, 20).Text(ValidationMode.Only).BindValue(ref nickName).State;
        }
        #endregion

        #region RealName
        /// <summary>
        /// RealName
        /// </summary>
        public string RealName
        {
            get { return m_RealName; }
            set
            {
                m_RealName = value;
                this.HasRealName = (!String.IsNullOrEmpty(value)) ? true : false;
            }
        }
        private string m_RealName;
        public bool HasRealName { get; private set; }
        public bool RealNameIsLike { get; set; }
        public static ExcuteState RealName_Validate(ref string realName)
        {
            return realName.Validation("RealName").LengthBetween(0, 20).Text(ValidationMode.Only).BindValue(ref realName).State;
        }
        #endregion

        #region Sex
        /// <summary>
        /// Sex
        /// </summary>
        public Pismire.ConstValues.Sex Sex
        {
            get { return m_Sex; }
            set
            {
                m_Sex = value;
                if (value.Validation("Sex").NotDefault().State.Succeed) HasSex = true;
            }
        }
        private Pismire.ConstValues.Sex m_Sex;
        public bool HasSex { get; private set; }
        #endregion

        #region Wedlock
        /// <summary>
        /// Wedlock
        /// </summary>
        public Pismire.ConstValues.Wedlock Wedlock
        {
            get { return m_Wedlock; }
            set
            {
                m_Wedlock = value;
                if (value.Validation("Wedlock").NotDefault().State.Succeed) HasWedlock = true;
            }
        }
        private Pismire.ConstValues.Wedlock m_Wedlock;
        public bool HasWedlock { get; private set; }
        #endregion

        #region Exp
        /// <summary>
        /// Exp
        /// </summary>
        public int Exp
        {
            get { return m_Exp; }
            set
            {
                m_Exp = value;
                if (!ExpComparisonModeFlag)
                {
                    ExpComparisonMode = QueryComparison.EqualTo;
                }
            }
        }
        private int m_Exp;
        public QueryComparison ExpComparisonMode
        {
            get { return m_ExpComparisonMode; }
            set
            {
                m_ExpComparisonMode = value;
                ExpComparisonModeFlag = true;
            }
        }
        private QueryComparison m_ExpComparisonMode;
        private bool ExpComparisonModeFlag = false;
        public static ExcuteState Exp_Validate(ref int exp)
        {
            return exp.Validation("Exp").Between(int.MinValue, int.MaxValue).State;
        }
        #endregion

        #region Score
        /// <summary>
        /// Score
        /// </summary>
        public int Score
        {
            get { return m_Score; }
            set
            {
                m_Score = value;
                if (!ScoreComparisonModeFlag)
                {
                    ScoreComparisonMode = QueryComparison.EqualTo;
                }
            }
        }
        private int m_Score;
        public QueryComparison ScoreComparisonMode
        {
            get { return m_ScoreComparisonMode; }
            set
            {
                m_ScoreComparisonMode = value;
                ScoreComparisonModeFlag = true;
            }
        }
        private QueryComparison m_ScoreComparisonMode;
        private bool ScoreComparisonModeFlag = false;
        public static ExcuteState Score_Validate(ref int score)
        {
            return score.Validation("Score").Between(int.MinValue, int.MaxValue).State;
        }
        #endregion

        #region Work
        /// <summary>
        /// Work
        /// </summary>
        public string Work
        {
            get { return m_Work; }
            set
            {
                m_Work = value;
                this.HasWork = (!String.IsNullOrEmpty(value)) ? true : false;
            }
        }
        private string m_Work;
        public bool HasWork { get; private set; }
        public bool WorkIsLike { get; set; }
        public static ExcuteState Work_Validate(ref string work)
        {
            return work.Validation("Work").LengthBetween(0, 20).Text(ValidationMode.Only).BindValue(ref work).State;
        }
        #endregion

        #region Phone
        /// <summary>
        /// Phone
        /// </summary>
        public string Phone
        {
            get { return m_Phone; }
            set
            {
                m_Phone = value;
                this.HasPhone = (!String.IsNullOrEmpty(value)) ? true : false;
            }
        }
        private string m_Phone;
        public bool HasPhone { get; private set; }
        public bool PhoneIsLike { get; set; }
        public static ExcuteState Phone_Validate(ref string phone)
        {
            return phone.Validation("Phone").LengthBetween(0, 20).Text(ValidationMode.Only).BindValue(ref phone).State;
        }
        #endregion

        #region Mobile
        /// <summary>
        /// Mobile
        /// </summary>
        public string Mobile
        {
            get { return m_Mobile; }
            set
            {
                m_Mobile = value;
                this.HasMobile = (!String.IsNullOrEmpty(value)) ? true : false;
            }
        }
        private string m_Mobile;
        public bool HasMobile { get; private set; }
        public bool MobileIsLike { get; set; }
        public static ExcuteState Mobile_Validate(ref string mobile)
        {
            return mobile.Validation("Mobile").LengthBetween(0, 20).Text(ValidationMode.Only).BindValue(ref mobile).State;
        }
        #endregion

        #region IM01
        /// <summary>
        /// IM01
        /// </summary>
        public string IM01
        {
            get { return m_IM01; }
            set
            {
                m_IM01 = value;
                this.HasIM01 = (!String.IsNullOrEmpty(value)) ? true : false;
            }
        }
        private string m_IM01;
        public bool HasIM01 { get; private set; }
        public bool IM01IsLike { get; set; }
        public static ExcuteState IM01_Validate(ref string im01)
        {
            return im01.Validation("IM01").LengthBetween(0, 20).Text(ValidationMode.Only).BindValue(ref im01).State;
        }
        #endregion

        #region IM02
        /// <summary>
        /// IM02
        /// </summary>
        public string IM02
        {
            get { return m_IM02; }
            set
            {
                m_IM02 = value;
                this.HasIM02 = (!String.IsNullOrEmpty(value)) ? true : false;
            }
        }
        private string m_IM02;
        public bool HasIM02 { get; private set; }
        public bool IM02IsLike { get; set; }
        public static ExcuteState IM02_Validate(ref string im02)
        {
            return im02.Validation("IM02").LengthBetween(0, 20).Text(ValidationMode.Only).BindValue(ref im02).State;
        }
        #endregion

        #region IM03
        /// <summary>
        /// IM03
        /// </summary>
        public string IM03
        {
            get { return m_IM03; }
            set
            {
                m_IM03 = value;
                this.HasIM03 = (!String.IsNullOrEmpty(value)) ? true : false;
            }
        }
        private string m_IM03;
        public bool HasIM03 { get; private set; }
        public bool IM03IsLike { get; set; }
        public static ExcuteState IM03_Validate(ref string im03)
        {
            return im03.Validation("IM03").LengthBetween(0, 20).Text(ValidationMode.Only).BindValue(ref im03).State;
        }
        #endregion

        #region IM04
        /// <summary>
        /// IM04
        /// </summary>
        public string IM04
        {
            get { return m_IM04; }
            set
            {
                m_IM04 = value;
                this.HasIM04 = (!String.IsNullOrEmpty(value)) ? true : false;
            }
        }
        private string m_IM04;
        public bool HasIM04 { get; private set; }
        public bool IM04IsLike { get; set; }
        public static ExcuteState IM04_Validate(ref string im04)
        {
            return im04.Validation("IM04").LengthBetween(0, 20).Text(ValidationMode.Only).BindValue(ref im04).State;
        }
        #endregion

        #region IM05
        /// <summary>
        /// IM05
        /// </summary>
        public string IM05
        {
            get { return m_IM05; }
            set
            {
                m_IM05 = value;
                this.HasIM05 = (!String.IsNullOrEmpty(value)) ? true : false;
            }
        }
        private string m_IM05;
        public bool HasIM05 { get; private set; }
        public bool IM05IsLike { get; set; }
        public static ExcuteState IM05_Validate(ref string im05)
        {
            return im05.Validation("IM05").LengthBetween(0, 20).Text(ValidationMode.Only).BindValue(ref im05).State;
        }
        #endregion

        #region Address
        /// <summary>
        /// Address
        /// </summary>
        public string Address
        {
            get { return m_Address; }
            set
            {
                m_Address = value;
                this.HasAddress = (!String.IsNullOrEmpty(value)) ? true : false;
            }
        }
        private string m_Address;
        public bool HasAddress { get; private set; }
        public bool AddressIsLike { get; set; }
        public static ExcuteState Address_Validate(ref string address)
        {
            return address.Validation("Address").LengthBetween(0, 20).Text(ValidationMode.Only).BindValue(ref address).State;
        }
        #endregion

        #region Signature
        /// <summary>
        /// Signature
        /// </summary>
        public string Signature
        {
            get { return m_Signature; }
            set
            {
                m_Signature = value;
                this.HasSignature = (!String.IsNullOrEmpty(value)) ? true : false;
            }
        }
        private string m_Signature;
        public bool HasSignature { get; private set; }
        public bool SignatureIsLike { get; set; }
        public static ExcuteState Signature_Validate(ref string signature)
        {
            return signature.Validation("Signature").LengthBetween(0, 20).Text(ValidationMode.Only).BindValue(ref signature).State;
        }
        #endregion

        #region Intro
        /// <summary>
        /// Intro
        /// </summary>
        public string Intro
        {
            get { return m_Intro; }
            set
            {
                m_Intro = value;
                this.HasIntro = (!String.IsNullOrEmpty(value)) ? true : false;
            }
        }
        private string m_Intro;
        public bool HasIntro { get; private set; }
        public bool IntroIsLike { get; set; }
        public static ExcuteState Intro_Validate(ref string intro)
        {
            return intro.Validation("Intro").LengthBetween(0, 20).Text(ValidationMode.Only).BindValue(ref intro).State;
        }
        #endregion

        #region Birthday
        /// <summary>
        /// Birthday
        /// </summary>
        public DateTime Birthday
        {
            get { return m_Birthday; }
            set
            {
                m_Birthday = value;
                if (value.Validation("Birthday").NotDefault().State.Succeed) HasBirthday = true;
            }
        }
        private DateTime m_Birthday;
        public bool HasBirthday { get; private set; }
        public static ExcuteState Birthday_Validate(ref DateTime birthday)
        {
            return birthday.Validation("Birthday").Between(Pismire.ConstValues.DateTime.MinValue, Pismire.ConstValues.DateTime.MaxValue).State;
        }
        #endregion

        #region checkMe
        /// <summary>
        /// 检查合法性
        /// </summary>
        /// <returns></returns>
        public override ExcuteState CheckMe()
        {
            //初始化
            ExcuteState state = new ExcuteState();

            state = NickName_Validate(ref this.m_NickName);
            if (!state.Succeed) return state;

            state = RealName_Validate(ref this.m_RealName);
            if (!state.Succeed) return state;

            state = Exp_Validate(ref this.m_Exp);
            if (!state.Succeed) return state;

            state = Score_Validate(ref this.m_Score);
            if (!state.Succeed) return state;

            state = Work_Validate(ref this.m_Work);
            if (!state.Succeed) return state;

            state = Phone_Validate(ref this.m_Phone);
            if (!state.Succeed) return state;

            state = Mobile_Validate(ref this.m_Mobile);
            if (!state.Succeed) return state;

            state = IM01_Validate(ref this.m_IM01);
            if (!state.Succeed) return state;

            state = IM02_Validate(ref this.m_IM02);
            if (!state.Succeed) return state;

            state = IM03_Validate(ref this.m_IM03);
            if (!state.Succeed) return state;

            state = IM04_Validate(ref this.m_IM04);
            if (!state.Succeed) return state;

            state = IM05_Validate(ref this.m_IM05);
            if (!state.Succeed) return state;

            state = Address_Validate(ref this.m_Address);
            if (!state.Succeed) return state;

            state = Signature_Validate(ref this.m_Signature);
            if (!state.Succeed) return state;

            state = Intro_Validate(ref this.m_Intro);
            if (!state.Succeed) return state;

            state = Birthday_Validate(ref this.m_Birthday);
            if (!state.Succeed) return state;

            //返回
            return state;
        }
        #endregion
    }
}
